package com.yt.website.filter;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class WebsiteConsumerFilter implements HandlerInterceptor {
	private Log log = LogFactory.getLog(WebsiteConsumerFilter.class);

	public boolean preHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler) throws Exception {
		log.debug("进入spring mvc拦截器");
		/* 1.检测用户 */
		return true;
	}

	/**
	 * 获取请求的相对的url
	 * 
	 * @param request
	 * @return
	 */
	private String getContextPath(HttpServletRequest request) {
		String uri = request.getServletPath();
		String pathInfo = request.getPathInfo();
		if (pathInfo != null && pathInfo.length() > 0) {
			uri = uri + pathInfo;
		}
		return uri;
	}

	public void postHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler,
			ModelAndView modelAndView) throws Exception {

	}

	public void afterCompletion(HttpServletRequest request,
			HttpServletResponse response, Object handler, Exception ex)
			throws Exception {

	}
}
